<?php
$text = "hTTp://lf1.me";
$pattern = "|^https?://[\d\w.\/;?:@&=+$,\-_!~*\'()#%]+$|i";
$pattern = "((((href|https?):((//)|(\\\\)))|(www.))[\w\d:#%/;$()~_?\\-=\.&]*)i";
preg_match_all($pattern, $text, $matches);
$urlArray = $matches[0];
echo print_r($urlArray);
echo "-------------";

$string = 'http://img.constantcontact.com/lp/images/standard/bv2/icon_home.png';

		// try to match our pattern
		if(preg_match("/(.gif|.jpg|.png)/i", $string))  {
			// echo this is it matches
			echo 'Found image url';
        }
		else {
			// if not match is found echo this line
			echo 'Not Found image url';       
        }
		
		$string = 'htsstpabcdefghijklmnopqrstuvwxyz0123456789';
		if(!preg_match("/^http/i", $string)) {
			if(preg_match("/^www./i", $string)) {
			$refUrl = "http://".$string;
			}					
		}	
		
		$url = 'http://img.constantcontact.com/lp/images/standard/bv2/icon_home.png';
		
		$pos = strrpos( $url, ".");
		echo "P:".$pos;
        if ($pos === false)
          return false;
        $ext = strtolower(trim(substr( $url, $pos)));
        $imgExts = array(".gif", ".jpg", ".jpeg", ".png", ".tiff", ".tif"); // this is far from complete but that's always going to be the case...
        if ( in_array($ext, $imgExts) ) {
			echo 'Found image url';
			//return true;
		}else{
			echo 'NOt Found image url';
			//return false;	
		}
		//echo "test";
		//echo isImage($url);
		echo "---------------------------";
		$url = ".../asdasd/.gif";
		isValidURL($url);
	function isImage($url)
	{
		$pos = strrpos( $url, ".");
        if ($pos === false)
          return false;
        $ext = strtolower(trim(substr( $url, $pos)));
        $imgExts = array(".gif", ".jpg", ".jpeg", ".png", ".tiff", ".tif"); // this is far from complete but that's always going to be the case...
        if ( in_array($ext, $imgExts) )
          return true;
		return false;
	}
	
	function isValidURL($url){
		// try to match url pattern
		$pattern = "((((https?):((//)|(\\\\)))|(www.))[\w\d:#%/;$()~_?\\-=\.&]*)i";
		if(preg_match($pattern, $url))  {
			//echo 'Found image url';
			return true;
        }
		else {
			return false;
			//echo 'Not Found image url';       
        }
	}
		
?>